home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / udos / fgrep103 / mkdescve.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-28  |  849 b   |  32 lines

  1. #include "bm.h"
  2. #include <string.h>
  3. #include "proto.h" /* N2 04-05-91 */
  4.  
  5. /* scan a newline-separated string of patterns and set up the
  6. * vector of descriptors, one pattern descriptor per pattern.
  7. * Return the number of patterns */
  8. int MkDescVec(struct PattDesc *DescVec[], char *Pats)
  9. /*
  10. struct PattDesc *DescVec[];
  11. char *Pats;
  12. */
  13. {
  14.         int NPats = 0;
  15.         char *EndPat;
  16.      //   extern struct PattDesc *MakeDesc();
  17.  
  18.         while (*Pats && (EndPat = strchr(Pats,'\n')) && NPats < MAXPATS)
  19.         {
  20.           *EndPat = NULL;
  21.           DescVec[NPats] = MakeDesc(Pats);
  22.           Pats = EndPat + 1;
  23.           ++NPats;
  24.         } /* while */
  25.         if (*Pats && NPats < MAXPATS)
  26.         {
  27.           DescVec[NPats] = MakeDesc(Pats);
  28.           ++NPats;
  29.         } /* if */
  30.         return(NPats);
  31. } /* MkDescVec */
  32.